package edu.dali.enterprise_test.controller;

import org.apache.poi.util.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;

@Controller
public class PictureController {
    @Value("${image.path}")
    private String imgPath;
    @RequestMapping("/getpic/{path}")
    public void getPic(HttpServletResponse response ,@PathVariable String path) throws IOException {
        FileInputStream fis = new FileInputStream(imgPath+path);
        response.getOutputStream().write(IOUtils.toByteArray(fis));
    }
}
